<?php
include_once '../samepart/header.php';
?>
<title>No.2商城-商品详情页</title>
<div style="margin: 0 auto; width: 90%;">
    <ol class="breadcrumb">
        <li><a href="../index.php">No.2商城</a></li>
        <li class="active" id="good_typename">
            <!--                <a href="goodsList.php?tn='$type_name'"></a>-->
        </li>
    </ol>
</div>
<div class="container">
    <div class="row">
        <div class="col-xs-6 col-md-6">
            <a href="#" class="thumbnail"> <img id="good_picture"
                                                src="" width="560" height="560"
                                                alt=""/>
            </a>
        </div>
        <div class="col-xs-6 col-md-6">
            <div class="panel panel-default" style="height: 560px">
                <div class="panel-heading">商品详情</div>
                <div class="panel-body">
                    <h3>
                        产品名称:<span id="good_name"></span>
                    </h3>
                    <div style="margin-left: 10px;">

                        <p>
                            市场价格:&nbsp;&nbsp;&nbsp;<span class="text-danger" id="good_price"
                                                         style="font-size: 15px;"></span><span
                                    class="glyphicon glyphicon-yen"></span>
                        </p>
                        <p>上市时间:&nbsp;&nbsp;&nbsp;<span id="good_pubdate"></span></p>
                        <p id="good_star">
                            热销指数:&nbsp;&nbsp;
                        </p>
                        <p>详细介绍:</p>
                        <p id="good_intro">&nbsp;&nbsp;</p>
                        <a id="addCart" href=""
                           class="btn btn-warning">加入购物车&nbsp;&nbsp;&nbsp;<span
                                    class="glyphicon glyphicon-shopping-cart"></span></a>&nbsp;&nbsp;&nbsp;
                        <!--<a
                                href="/chapter16/getDirectOrder?id=&price=&name="
                                class="btn btn-warning">直接购买&nbsp;&nbsp;&nbsp;<span
                                    class="glyphicon glyphicon-shopping-cart"></span></a>-->
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php include_once '../samepart/footer.php' ?>
<script type="text/javascript">

    /**
     * 显示商品详细信息
     */
    $(function () {
        $.ajax({
            url: "http://www.lyd.com/phalapi/public/index.php?s=App.Goods.getGoodInfo",
            type: "GET",
            data: {
                "good_id": '<?php echo $_GET['actionId'];$_SESSION["goodID"] = $_GET['actionId']; ?>'
            },
            dataType: "JSON",
            success: function (result) {
                var username_data = result.data.info;
                // $type_name=username_data.typeName
                // console.log("data:" + username_data.id)
                var goodPicture_src = '../assets/fmwimages/' + username_data.picture
                var price = username_data.price;
                var id = username_data.id;
                var purl = window.location.pathname + window.location.search;//获取地址
                purl = purl.substring(12, 48)/*purl.indexOf('/', 50)*///切割地址
                // console.log(purl)
                $("#good_name").text(username_data.name)
                $("#good_price").text(username_data.price)
                $("#good_pubdate").text(username_data.pubdate)
                $("#good_picture").attr("src", goodPicture_src)
                $("#good_intro").text(username_data.intro)
                $("#good_typename").html("<a href='goodsList.php?actionGoodTypeName=" + username_data.typeName + "'>" + username_data.typeName + "</a>")
                $("#addCart").attr("href", "../cart/carSuccess.php?insert=icd&price=" + price + "&gid=" + id + "&purl=" + purl)
                // $("#good_typename").text(username_data.typeName)
                for (var i = 0; i < username_data.star; i++) {
                    var imgs = $("<img src='../assets/image/star_red.gif'/>");
                    $("#good_star").append(imgs);
                }
            },
            error: function (msg) {
                alert("错误信息：" + msg);
            }
        })
    })

</script>
